<template>
  <div class="container">
    <DocHeader :title="title" :diagnosis="true" />
    <div class="content">
      <div class="flex borb bort borl">
        <div class="flex-1 pad8 tac" style="border-right: 1px solid #fff">
          项目
        </div>
        <div class="flex flex-8">
          <div class="flex-4 borr tac"></div>
          <div class="flex-3 borr pad8 tac">教育日期</div>
          <div class="flex-2 borr pad8 tac">教育方法</div>
          <div class="flex-2 borr pad8 tac">教育对象</div>
          <div class="flex-2 borr pad8 tac">教育者</div>
          <div class="flex-2 borr pad8 tac">效果评价</div>
          <div class="flex-2 borr pad8 tac">评价者</div>
        </div>
      </div>
      <!--  -->
      <div
        v-for="itemss in pageData.list"
        :key="itemss.title"
        class="flex borl"
      >
        <div class="flex-1 tac borb borr">{{ itemss.title }}</div>
        <div class="flex-8">
          <div v-for="items in itemss.list" :key="items.title" class="flex">
            <div class="flex-4 borr borb pad8">
              <div class="pad5">{{ items.title }}</div>
            </div>
            <div
              v-for="(item, index) in items.list"
              :key="index"
              class="flex-2 borr borb pad8 tac"
              :class="[index === 0 ? 'flex-3' : '']"
            >
              <el-input v-model="item.value" class="input"></el-input>
            </div>
          </div>
        </div>
      </div>
      <div class="flex mb8 mt8">
        教育方法:
        <el-radio-group v-model="pageData.radio1">
          <el-radio label="a书写/印刷"></el-radio>
          <el-radio label="b口述/讨论"></el-radio>
          <el-radio label="c示范"></el-radio>
        </el-radio-group>
      </div>
      <div class="flex mb8">
        教育对象:
        <el-radio-group v-model="pageData.radio2">
          <el-radio label="a患者"></el-radio>
          <el-radio label="b家属"></el-radio>
        </el-radio-group>
      </div>
      <div class="flex">
        <span @click="getParams">效果评估:</span>
        <el-radio-group v-model="pageData.radio3">
          <el-radio label="a口述理解"></el-radio>
          <el-radio label="b会演示"></el-radio>
          <el-radio label="c需强化"></el-radio>
        </el-radio-group>
      </div>
    </div>
  </div>
</template>
<script>
import { cloneDeep } from 'lodash-unified'
import {
  defineComponent,
  nextTick,
  onMounted,
  reactive,
  toRefs,
  watch
} from 'vue'

import DocHeader from '../DocHeader.vue'
import { baseData } from './baseData.js'

export default defineComponent({
  components: {
    DocHeader
  },
  props: {
    data: {
      type: Object,
      default: () => ({})
    },
    patCur: {
      type: Object,
      default: () => ({})
    },
    formType: {
      type: String,
      default: 'add'
    },
    type: {
      type: String,
      default: ''
    },
    idx: {
      type: Number,
      default: 0
    },
    title: {
      type: String,
      default: ''
    }
  },
  setup(props) {
    const state = reactive({
      pageData: ''
    })

    function initData() {
      if (props.data.jsonText && props.data.jsonText !== '{}') {
        const jsonText = JSON.parse(props.data.jsonText)
        state.pageData = Object.assign(cloneDeep(baseData()), jsonText)
      } else {
        nextTick(() => {
          state.pageData = baseData()
        })
      }
    }

    function getParams() {
      return state.pageData
    }

    watch(
      () => props.data,
      () => {
        initData()
      }
    )

    onMounted(() => {
      initData()
    })

    return {
      ...toRefs(state),
      getParams
    }
  }
})
</script>

<style lang="scss" scoped>
@import '@/views/doc/styles/doc-common.scss';
$border: 1px solid #000;

.container {
  padding: 20px;
  font-family: SiYuanSong-Medium;
  text-align: start;

  .content {
    margin-top: 8px;
  }
}

.input {
  width: 80%;

  :deep {
    .el-input__inner {
      border: none;
      font-size: 13px;
      color: #000;
      padding: 0;
      line-height: 1;
      height: 16px;
    }
  }
}

.flex {
  display: flex;
}

.tac {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.h30 {
  height: 30px;
}

.sta {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.flex {
  @for $i from 1 through 30 {
    &-#{$i} {
      flex: $i;
    }
  }
}

.sign {
  flex-flow: column nowrap;
  align-items: flex-end;
  margin-top: 50px;

  & > div {
    width: 30%;
  }

  .nurse {
    margin-top: 20px;
  }

  .time {
    margin-top: 20px;
  }
}

.mb8 {
  margin-bottom: 8px;
}

.mt8 {
  margin-top: 8px;
}

.borr {
  border-right: 1px solid #000;
}

.bort {
  border-top: 1px solid #000;
}

.borl {
  border-left: 1px solid #000;
}

.borb {
  border-bottom: 1px solid #000;
}

.pad10 {
  padding: 10px;
}

.pad8 {
  padding: 6px 0;
}

.pad5 {
  padding: 0 5px;
}
</style>
